#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "ui/widget/stackedwidget/stackeddialog.h"
#include "ui/widget/systemtrayicondemo.h"
#include <QMetaObject>
#include <QDebug>
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);    
    createBaseWidgetMenu();
    qDebug()<<"Width:"<<this->width();
    qDebug()<<"Height:"<<this->height();
    qDebug()<<"centralWidget()->width():"<<centralWidget()->width();
    qDebug()<<"centralWidget()->height():"<<centralWidget()->height();

    setFixedSize(800,600);
}

MainWindow::~MainWindow()
{
    delete ui;
}
void MainWindow::createBaseWidgetMenu()
{
    QMenu* widgetMenu=ui->menubar->addMenu("基础Widget");    
    /**
      UI相关
     */
    //QSystemTrayIcon
    widgetMenu->addAction("QSystemTrayIcon",this,SLOT(QSystemTrayIconDemo()));

    widgetMenu->addSeparator();
    widgetMenu->addAction("QVBoxLayout",this,SLOT(QVBoxLayoutDemo()));
    widgetMenu->addAction("QStackedLayout",this,SLOT(QStackedLayoutDemo()));
    widgetMenu->addAction("QGridLayout",this,SLOT(QGridLayoutDemo()));

    widgetMenu->addSeparator();
    widgetMenu->addAction("Clock",this,SLOT(ClockDemo()));
    widgetMenu->addAction("内部对话框",this,SLOT(DialogDemo()));
    widgetMenu->addAction("颜色选择",this,SLOT(ColorDemo()));


    /**
      网络通信相关
    */
    QMenu* networkMenu=ui->menubar->addMenu("网络通信");
    networkMenu->addAction("QSSLSocket",this,SLOT(SSLSocketDemo()));
    networkMenu->addAction("QWebSocket",this,SLOT(WebSocketDemo()))->setData("WebSocketDemo");
    //ToDo
    //HTTP/HTTPS
    //TCP Client/Server
    //UDP BroadCast


    /**
        Model/View
      */
    QMenu* modelViewMenu=ui->menubar->addMenu("Model/View");
    modelViewMenu->addAction("QTreeViewDemo",this,SLOT(TreeViewDemo()));

    /**
      数据存储
      */
    //ToDo
    //Database
    //QSetting
    //File Stream

    /**
     * Qt FrameWork
    */
    //MetaObject System


    /**
     * Other
     * */
    //QFileSystemWatcher
    //QProcess
    //QApplication/QCoreApplication
}
void MainWindow::QVBoxLayoutDemo()
{

}
void MainWindow::QStackedLayoutDemo()
{
    StackedDialog dialog;
    dialog.exec();
}
#include "ui/widget/gridlayoutdemo.h"
void MainWindow::QGridLayoutDemo()
{
    GridLayoutDemo* demo=new GridLayoutDemo;
    demo->show();
}
void MainWindow::QSystemTrayIconDemo()
{
    SystemTrayIconDemo *systemTrayIconDemo=new SystemTrayIconDemo(this);
    systemTrayIconDemo->show();
    //systemTrayIconDemo->showMessage("title","message");
}
#include "ui/demo/myclockdemo.h"
#include <QDebug>
void MainWindow::ClockDemo()
{
    qDebug()<<"ClockDemo";
    MyClockDemo * demo=new MyClockDemo(this);
    demo->show();
}
#include "ui/demo/dialogdemo.h"
void MainWindow::DialogDemo()
{
    InnerDialogDemo* demp=new InnerDialogDemo(this);
    demp->show();
}
#include "ui/demo/colorselectdialog.h"
void MainWindow::ColorDemo(){
    ColorSelectDialog* dialog=new ColorSelectDialog(this);
    dialog->show();
}
#include "network/ssl/ssldemo.h"
void MainWindow::SSLSocketDemo()
{
    SSLDemo demo;
    demo.exec();
}

#include "network/websocket/websocketdemo.h"
void MainWindow::WebSocketDemo()
{
    QWebSocketDemo demo;
    demo.exec();
}
#include "ui/model/qtreeviewdemo.h"
void MainWindow::TreeViewDemo()
{
    QTreeViewDemo* demo=new QTreeViewDemo(this);
    demo->show();
}
